<include file="Public:header" />
<style>
.green-tab > li.active{
	background-color:#18a689;
}
.green-tab > li > a:hover{
	background-color:#18a689;
	color:#fff;
}
</style>
<div class="wrapper wrapper-content animated fadeIn">
	<include file="Public:alert" />
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
				<!-- <div class="col-sm-2">
					<ul class="nav nav-list green-tab" style="background:#fff;color:#134D77;min-height:77%;margin-top:0px;">
						<li class="active">
							<a href="javascript:void(0);" style="font-weight:blod;background-color:#eeeeee;color:#134D77">{:L('VIEW_BY_LOG_CATEGORY')}</a>
						</li>
						<li <if condition="$_GET['module'] eq null">class="active"</if>><a href="{:U('log/anly','by='.$_GET['by'])}">{:L('ALL')}</a></li>
						<li <if condition="$_GET['module'] == 'customer'">class="active"</if>><a  href="{:U('Log/anly','r=rCustomerLog&module=customer&by='.$_GET['by'])}">{:L('CUSTOMER')}</a></li>
						<li <if condition="$_GET['module'] == 'business'">class="active"</if> ><a href="{:U('Log/anly','r=rBusinessLog&module=business&by='.$_GET['by'])}">{:L('BUSINESS')}</a></li>
						<li <if condition="$_GET['module'] == 'leads'">class="active"</if>><a  href="{:U('Log/anly','r=rLeadsLog&module=leads&by='.$_GET['by'])}">{:L('LEADS')}</a></li>
						<li <if condition="$_GET['module'] == 'task'">class="active"</if>><a  href="{:U('Log/anly','r=rLogTask&module=task&by='.$_GET['by'])}">{:L('TASK')}</a></li>
						<li <if condition="$_GET['module'] == 'event'">class="active"</if> ><a href="{:U('Log/anly','r=rEventLog&module=event&by='.$_GET['by'])}">{:L('EVENT')}</a></li>
						<li <if condition="$_GET['module'] == 'contacts'">class="active"</if>><a  href="{:U('Log/anly','r=rContactsLog&module=contacts&by='.$_GET['by'])}">{:L('CONTACTS')}</a></li>
					</ul>
				</div> -->
				<div class="col-sm-12">
					<div class="ibox-content" style="padding-bottom:1px;padding-top:10px">
						<p class="view2">&nbsp;&nbsp;&nbsp;&nbsp;<b>{:L('VIEW_NAV')}</b>&nbsp;&nbsp;&nbsp;
							<span class="fa fa-clock-o"></span> <a href="{:U('log/anly','by=all')}" <if condition="$Think.get.by eq 'all'">class="active"</if>>{:L('ALL')}</a> | 
							<a href="{:U('log/anly','by=today')}" <if condition="$Think.get.by eq 'today'">class="active"</if>>{:L('CREATE_TODAY')}</a> | 
							<a href="{:U('log/anly','by=week')}" <if condition="$Think.get.by eq 'week'">class="active"</if>>{:L('CREATE_THIS_WEEK')}</a> | 
							<a href="{:U('log/anly','by=month')}" <if condition="$Think.get.by eq 'month'">class="active"</if>>{:L('CREATE_THIS_MONTH')}</a>
						</p>
					</div>
					<div style="margin-top:10px;background-color:#fff">
						<div class="row-fluid">
							<div class="col-sm-12" style="padding:18px 0px 0px 15px;">
								<div class="pull-left">
									<ul class="nav pull-left">
										<a id="delete" class="btn  btn-primary btn-sm" style="margin-right: 5px;"><i class="fa fa-remove"></i>&nbsp;&nbsp;{:L('DELETE')}</a>
										<!-- <if condition="$_GET['type'] == 1">
											<select style="width:auto;"  class="nav pull-left" id="module" onchange="changeContent()">
												<option <if condition="$_GET['module'] == null">selected</if> value="6">全部模块</option>
												<option <if condition="$_GET['module'] == 'customer'">selected</if> value="1">客户</option>
												<option <if condition="$_GET['module'] == 'contacts'">selected</if> value="2">联系人</option>
												<option <if condition="$_GET['module'] == 'business'">selected</if> value="3">商机</option>
												<option <if condition="$_GET['module'] == 'task'">selected</if> value="4">任务</option>
												<option <if condition="$_GET['module'] == 'event'">selected</if> value="5">日程</option>
											</select>
										</if> -->
									</ul>
									<li class="nav pull-left">
										<form class="form-inline" id="searchForm" action="index.php" method="get">
											<ul class="nav pull-left">
												<!-- <li class="pull-left">
													{:L('ROLE_NAME')}&nbsp; <select style="width:auto" name="role" id="role" >
														<option class="all" value="all">{:L('ALL')}</option>
														<volist name="role_list" id="vo">
															<option <if condition="$_GET['role'] == $vo.role_id">selected="selected"</if> value="{$vo.role_id}">{$vo.role_name}-{$vo.user_name}</option>
														</volist>
													</select>&nbsp;&nbsp;
												</li> -->
												<li class="pull-left">{:L('ROLE_NAME')}&nbsp; </li>
												<li class="pull-left" style="width:200px;">
													<select class="selectpicker show-tick form-control input-sm" data-live-search="true" id="role" name="role" style="width:auto">
														<option class="all" value="all">{:L('ALL')}</option>
														<volist name="role_list" id="vo">
															<option <if condition="$_GET['role'] == $vo.role_id">selected="selected"</if> value="{$vo.role_id}">{$vo.role_name}-{$vo.user_name}</option>
														</volist>
													</select>
												</li>
												
												<li class="pull-left">
													&nbsp;&nbsp;{:L('SELECT DATE')}&nbsp; {:L('FROM')}<input type="text" id="start_time" name="start_time" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" class="Wdate form-control input-sm" style="width:auto;" value="{$Think.get.start_time}"/>{:L('TO')}<input type="text" id="end_time" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" style="width:auto;" name="end_time" class="Wdate form-control input-sm" value="{$Think.get.end_time}" />&nbsp;&nbsp;
												</li>
												
												<li class="pull-left"><input type="hidden" name="m" value="log"/><input type="hidden" name="a" value="anly"/>
												<if condition="$Think.get.by neq null"><input type="hidden" name="by" value="{$Think.get.by}"/></if>
												<if condition="$Think.get.type neq null"><input type="hidden" name="type" value="{$Think.get.type}"/></if>
												<if condition="$Think.get.module neq null"><input type="hidden" name="module" value="{$Think.get.module}"/></if>
												<if condition="$Think.get.r neq null"><input type="hidden" name="r" value="{$Think.get.r}"/></if>
												<button type="submit" class="btn  btn-primary btn-sm"><span class="fa fa-search"></span>&nbsp;&nbsp;{:L('SEARCH')}</button></li>
												
											</ul>
										</form>
									</li>
								</div>
								<div class="pull-right" style="margin-right:15px;">
									<a href="{:U('log/mylog_add')}" class="btn btn-primary btn-sm"><i class="fa fa-plus"></i>&nbsp; {:L('ADD_LOG')}</a>
								</div>
							</div>
							<div class="col-sm-12" style="margin-left:0px;">
								<form id="form1" method="post">
									<table class="table table-hover table-striped">
										<if condition="$list eq null">
											<tr><td>{:L('EMPTY_TPL_DATA')}</td></tr>
										<else/>
											<thead>
												<tr>
													<th><input id="check_all" class="control_all" type="checkbox" /></th>
													<th width="10px"></th>
													<th>{:L('SUBJECT')}</th>
													<th>{:L('ROLE_NAME')}</th>
													<if condition = "($_GET['module'] eq '')">
														<th>{:L('BELONG_TO')}</th>
													<elseif condition = "($_GET['module'] eq 'customer')" />
														<th>{:L('BELONG_TO')}</th>
													<elseif condition = "($_GET['module'] eq 'contacts')" />
														<th>{:L('BELONG_TO_CONTACTS')}</th>
													<elseif condition = "($_GET['module'] eq 'business')" />
														<th>{:L('BELONG_TO_BUSINESS')}</th>
													<elseif condition = "($_GET['module'] eq 'task')" />
														<th>{:L('BELONG_TO_TASK')}</th>
													<elseif condition = "($_GET['module'] eq 'event')" />
														<th>{:L('BELONG_TO_EVENT')}</th>
													<elseif condition = "($_GET['module'] eq 'leads')" />
														<th>{:L('BELONG_TO_LEADS')}</th>
													</if>
													<if condition="$_GET['module'] eq 'business' || $_GET['module'] eq 'leads'">
														<th style="width:20%">{:L('NEXT_LINK')}</th>
													</if>
													<th style="width:16%">
														<if condition="$_GET['asc_order'] == 'create_date'">
															<a href="{:U('log/anly','desc_order=create_date&'.$parameter)}">
																{:L('CREATE_TIME')}&nbsp;<span class="fa fa-caret-up"></span>
															</a>
														<elseif condition="$_GET['desc_order'] == 'create_date'"/>
															<a href="{:U('log/anly','asc_order=create_date&'.$parameter)}">
																{:L('CREATE_TIME')}&nbsp;<span class="fa fa-caret-down"></span>
															</a>
														<else/>
															<a href="{:U('log/anly','desc_order=create_date&'.$parameter)}">{:L('CREATE_TIME')}</a>
														</if>
													</th>
													<th style="width:6%"></th>
												</tr>
											</thead>
											<tfoot>
												<tr>
													<td colspan="8">
														<p>{:L('NOTE_')}<span style="color:green"><i class="fa fa-check-square-o"></i></span>{:L('HAVE_SUPERIORS_COMMENTS')} &nbsp; &nbsp;  <span style="color:red"><i class="fa fa-edit"></i></span>{:L('NO_SUPERIORS_COMMENTS')}</p>
														{$page}
													</td>
												</tr>
											</tfoot>
											<tbody>
												<volist name="list" id="vo">
												<tr class="controls_tr">
													<td><input class="check_list" type="checkbox" name="log_id[]" value="{$vo.log_id}"/></td>
													<td><if condition="$vo['is_comment']"><span style="color:green"><i class="fa fa-check-square-o"></i></span><else /><span style="color:red"><i class="fa fa-edit"></i></span></if></td>
													<td><a href="{:U('log/mylog_view','id='.$vo['log_id'].'&type='.$_GET['type'])}"><if condition="$vo['subject'] ">{$vo.subject}<else />{$vo['content']|msubstr=###,0,20}...</if></a></td>
													<td><notempty name="vo.creator.user_name"><a class="role_info" rel="{$vo.creator.role_id}" href="javascript:void(0)">{$vo.creator.user_name}</a></notempty></td>

													<td>
														<if condition="$vo['customer_name'] neq null">{:L('RELATED_CUSTOMER')}:
															<a href="{:U('customer/view','id='.$vo['customer_id'])}" target="blank">{$vo.customer_name}</a>
														<elseif condition="$vo['contacts_name'] neq null" />{:L('RELATED_CONTACTS')}:
															<a href="{:U('contacts/view','id='.$vo['contacts_id'])}" target="blank">{$vo.contacts_name}</a>
														<elseif condition="$vo['business_name'] neq null" />{:L('RELATED_BUSINESS')}:
															<a href="{:U('business/view','id='.$vo['business_id'])}" target="blank">{$vo.business_name}</a>
														<elseif condition="$vo['task_name'] neq null" />{:L('RELATED_TASK')}:
															<a href="{:U('task/view','id='.$vo['task_id'])}" target="blank">{$vo.task_name}</a>
														<elseif condition="$vo['event_name'] neq null" />{:L('RELATED_EVENT')}:
															<a href="{:U('event/view','id='.$vo['event_id'])}" target="blank">{$vo.event_name}</a>
														<elseif condition="$vo['leads_name'] neq null" />{:L('RELATED_LEADS')}:
														<a href="{:U('leads/view','id='.$vo['leads_id'])}" target="blank">{$vo.leads_name}</a>
														<elseif condition="$vo['product_name'] neq null" />营销产品:
														<a href="{:U('product/view','id='.$vo['product_id'])}" target="blank">{$vo.product_name}</a>
														<else />
															{:L('NONE')}
														</if>
													</td>
													<if condition="$_GET['module'] eq 'business' || $_GET['module'] eq 'leads'">
														<td><if condition="$vo['nextstep_time']">{$vo.nextstep_time|date="Y-m-d H:i",###} &nbsp; {$vo.nextstep}</if></td>
													</if>
													<td>{$vo.create_date|date="Y-m-d H:i",###}</td>
													<td>
														<span class="controls" style="display:none;">
															<a href="{:U('log/mylog_view','id='.$vo['log_id'].'&type='.$vo['category_id'])}" title="{:L('VIEW')}"><i class="fa fa-list"></i></a>&nbsp;&nbsp;&nbsp;
															<if condition = "$vo['category_id'] eq 1">
																<a href="javascript:void(0)" rel="{$vo.log_id}" class="edit_log" title="{:L('EDIT')}"><i class="fa fa-pencil"></i></a>
															<else/>
																<a href="{:U('log/mylog_edit','id='.$vo['log_id'].'&type='.$vo['category_id'])}" title="{:L('EDIT')}"><i class="fa fa-pencil"></i></a>
															</if>
														</span>
													</td>
												</tr>
												</volist>
											</tbody>
										</if>
									</table>
								</form>
							</div>
						</div>
					</div>
				</div>
            </div>
        </div>
    </div>
</div>
<div style="display:none;" id="dialog-role-info" title="{:L('DIALOG_USER_INFO')}">loading...</div>
<div style="display:none;" id="dialog-log-edit" title="{:L('EDIT_LOG')}">loading...</div>
<script type="text/javascript">
$(".controls_tr").mouseenter(function(){
	$(this).find(".controls").show();
}).mouseleave(function(){
	$(this).find(".controls").hide();
});

$("#dialog-role-info").dialog({
    autoOpen: false,
    modal: true,
	width: 600,
	maxHeight: 550,
	position: ["center",100]
});
$("#dialog-log-edit").dialog({
    autoOpen: false,
    modal: true,
	width: 600,
	maxHeight: 400,
	position: ["center",100]
});
$(function(){
	<if condition="$Think.get.role neq null">
		$("#role option[value='{$Think.get.role}']").prop("selected", true);
	</if>
	$('#delete').click(function(){
		var id_array = new Array();
		$("input[class='check_list']:checked").each(function(){
			id_array.push($(this).val());
		});
		if(id_array.length == 0){
			alert('{:L('你没有选中任何选项')}');
		}else{
			$("#form1").attr('action', '{:U("log/log_delete")}');
			$("#form1").submit();
		}
	});
	$(".role_info").click(function(){
		$role_id = $(this).attr('rel');
		$('#dialog-role-info').dialog('open');
		$('#dialog-role-info').load('{:U("user/dialoginfo","id=")}'+$role_id);
	});
	$(".edit_log").click(function(){
		$log_id = $(this).attr('rel');
		$('#dialog-log-edit').dialog('open');
		$('#dialog-log-edit').load('{:U("log/edit","id=")}'+$log_id);
	});
	$("#check_all").click(function(){
		$("input[class='check_list']").prop('checked', $(this).prop("checked"));
	});
})

</script>
<include file="Public:footer" />
